Skip to content

fix(queue): guard review/pause/resume/explain/generate-tests against webhook redelivery - #9398

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-9312
Jul 27, 2026
Merged

fix(queue): guard review/pause/resume/explain/generate-tests against webhook redelivery#9398
JSONbored merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-9312

Conversation

@bitfathers94

Copy link
Copy Markdown
Contributor

fix(queue): guard review/pause/resume/explain/generate-tests against webhook redelivery

The four throttle functions (maybeThrottleReviewNagPing and siblings) already
short-circuit a redelivered issue_comment via hasAuditEventForDelivery over the
COMMAND_RATE_LIMIT_REDELIVERY_WINDOW_MS window, but the five earlier-dispatched
action-command handlers had no equivalent guard. A GitHub redelivery (queue
max_retries:3 plus the dlq re-drive reuse the identical deliveryId) therefore
re-ran each handler's side effect a second time: a repeat re-review dispatch,
pause/resume state change, explanation comment, or E2E test regeneration.

Each handler now runs the same redelivery short-circuit keyed on its own
completed audit-event type, placed before any side-effecting work, plus a
per-handler redelivery test asserting the replay is a no-op.

Closes #9312

Validation

Verified locally on this branch before opening:

  • npm run typecheck
  • npx turbo run build:tsc build:verify
  • npm run test:coverage — patch coverage 100.0% of changed lines

…webhook redelivery

The four throttle functions (maybeThrottleReviewNagPing and siblings) already
short-circuit a redelivered issue_comment via hasAuditEventForDelivery over the
COMMAND_RATE_LIMIT_REDELIVERY_WINDOW_MS window, but the five earlier-dispatched
action-command handlers had no equivalent guard. A GitHub redelivery (queue
max_retries:3 plus the dlq re-drive reuse the identical deliveryId) therefore
re-ran each handler's side effect a second time: a repeat re-review dispatch,
pause/resume state change, explanation comment, or E2E test regeneration.

Each handler now runs the same redelivery short-circuit keyed on its own
completed audit-event type, placed before any side-effecting work, plus a
per-handler redelivery test asserting the replay is a no-op.
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.53%. Comparing base (9f56b2a) to head (bae1433).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9398      +/-   ##
==========================================
+ Coverage   75.46%   76.53%   +1.07%     
==========================================
  Files         275      276       +1     
  Lines       58030    61442    +3412     
  Branches     6199     7435    +1236     
==========================================
+ Hits        43790    47025    +3235     
- Misses      13970    14032      +62     
- Partials      270      385     +115     
Flag Coverage Δ
backend 94.81% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/queue/processors.ts 94.81% <100.00%> (ø)

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 27, 2026
@loopover-orb

loopover-orb Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-27 17:16:30 UTC

3 files · 1 AI reviewer · no blockers · CI green · clean

⏸️ Suggested Action - Manual Review

Review summary
This PR adds a redelivery short-circuit (mirroring the existing throttle-function pattern) to the five action-command handlers — review, pause, resume, explain, generate-tests — keyed on the completed audit-event type for each, checked via hasAuditEventForDelivery before any side-effecting work. Each handler gets a matching redelivery test asserting the replay is a no-op for both the side effect (dispatch/state-change/comment/AI-run) and the audit-event count, which is the right way to prove this. The guard's placement (before the pr/settings fetch) and its narrow, mechanical repetition across five near-identical call sites is consistent with the existing maybeThrottleReviewNagPing precedent cited in the comments.

Nits — 4 non-blocking
  • The same 6-line guard block (compute redeliverySinceIso, call hasAuditEventForDelivery) is duplicated five times almost verbatim across processors.ts — consider factoring it into a small helper (e.g. `shortCircuitOnRedelivery(env, actor, eventType, targetKey, deliveryId)`) to avoid five copies of the same window-computation logic drifting apart later.
  • Each redelivery test seeds fresh AI/fetch stubs per handler rather than sharing a small test helper for the 'process job twice with same deliveryId' pattern, which is fine but adds to the already very large queue-3/queue-5 test files.
  • Factor the repeated `redeliverySinceIso` + `hasAuditEventForDelivery` check into a shared helper function in processors.ts or a small utility module, since the five call sites are byte-for-byte identical apart from the event type string.
  • Consider whether `hasAuditEventForDelivery`'s window (COMMAND_RATE_LIMIT_REDELIVERY_WINDOW_MS) is documented as covering the realistic GitHub redelivery timeframe (immediate retries plus DLQ re-drive latency) since that's the crux of the fix's correctness.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #9312
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 80 registered-repo PR(s), 54 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor bitfathers94; Gittensor profile; 80 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
All five handlers (review, pause, resume, explain, generate-tests) get the identical hasAuditEventForDelivery guard keyed on each handler's own completed audit event type, placed before side-effecting work, mirroring maybeThrottleReviewNagPing as required and leaving the four throttle functions untouched.

Review context
  • Author: bitfathers94
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: TypeScript
  • Official Gittensor activity: 80 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

Decision record
  • action: hold · clause: ai_review_inconclusive
  • config: bf89114090f84769407c3188ab962fbbe4036e3a58459c2badb2b9a96a66fffd · pack: oss-anti-slop · ci: passed
  • record: 361c3fdb0471d2de83974d1ac9883852dc50094aec93a9a6664bd05338b82310 (schema v5, head bae1433)

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 27, 2026
@JSONbored
JSONbored merged commit 6397d3c into JSONbored:main Jul 27, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

queue: 5 action-command handlers (review/pause/resume/explain/generate-tests) missing the webhook-redelivery guard #8681 added elsewhere

2 participants